import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// 引入公共样式
import 'common/style/common.less'
// 引入ui框架
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VCharts from 'v-charts';
//引入公用方法
import utilJs from '@/common/js/util.js'
Vue.prototype.$util = utilJs;




// import VueQuillEditor from 'vue-quill-editor'
 
// // require styles
// import 'quill/dist/quill.core.css'
// import 'quill/dist/quill.snow.css'
// import 'quill/dist/quill.bubble.css'
 
// Vue.use(VueQuillEditor, /* { default global options } */)
import filters from './filters.js'
for (const key in filters) {
  if (filters.hasOwnProperty(key)) {
    Vue.filter(key, filters[key])
  }
}
// 引入星空组件
import eleVueParticles from 'vue-particles'
Vue.use(eleVueParticles);
Vue.use(ElementUI);
Vue.use(VCharts)
Vue.config.productionTip = false
router.beforeEach((to, from, next) => {
  // console.log(to);
  if (!to.meta.notoken) {  // 判断该路由是否需要登录权限
    let info = utilJs.getUserInfo();
    let bUserName = info.username || '';
    let bDeptID = info.deptid || '';
    if(!bUserName || !bDeptID) {
      next({ path: `/login`})
    } else {
      next()
    }
  }
  else {
    next();
  }
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
